package com.mobilekites.activities;

import android.os.Bundle;

import com.mobilekites.ad.AdKites;
import com.mobilekites.ad.Admob;
import com.mobilekites.ad.Admob.AdmobImpl;
import com.mobilekites.ad.Airpush;
import com.mobilekites.ad.Airpush.AirpushPlayStore;
import com.mobilekites.ad.CleverAd;
import com.mobilekites.ad.CleverAd.CleverAdImpl;
import com.mobilekites.ad.StartApp;
import com.mobilekites.ad.StartApp.StartAppImpl;

public abstract class AdKitesActivity extends KitesActivity implements AdKites {
	private AdmobImpl mAdmob;
	private AirpushPlayStore mAirpushPlayStore;
	private CleverAdImpl mCleverAdImpl;
	private StartAppImpl mStartAppImpl;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView();
		initAds();
	}

	private void initAds() {
		if (hasAdmob()) {
			mAdmob = new AdmobImpl(this);
			mAdmob.onCreate();
		}
		if (hasAirpush()) {
			mAirpushPlayStore = new AirpushPlayStore(this);
			mAirpushPlayStore.onCreate();
		}
		if (hasCleverAd()) {
			mCleverAdImpl = new CleverAdImpl(this);
		}
		if (hasStartApp()) {
			mStartAppImpl = new StartAppImpl(this);
			mStartAppImpl.onCreate();
		}
	}

	protected boolean hasAdmob() {
		return true;
	}

	protected boolean hasCleverAd() {
		return true;
	}

	protected boolean hasStartApp() {
		return true;
	}

	protected boolean hasAirpush() {
		return true;
	}

	@Override
	protected void onResume() {
		super.onResume();
		if (mAirpushPlayStore != null)
			mAirpushPlayStore.onResume();
		if (mStartAppImpl != null)
			mStartAppImpl.onResume();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		if (mAirpushPlayStore != null)
			mAirpushPlayStore.onDestroy();
	}

	@Override
	public void showErrorDialog(String s, String s1, boolean flag) {

	}

	@Override
	public Admob getAdmob() {
		return mAdmob;
	}

	@Override
	public Airpush getAirpush() {
		return mAirpushPlayStore;
	}

	@Override
	public CleverAd getCleverAd() {
		return mCleverAdImpl;
	}

	@Override
	public StartApp getStartApp() {
		return mStartAppImpl;
	}

	@Override
	protected void onPause() {
		super.onPause();
		if (mAirpushPlayStore != null)
			mAirpushPlayStore.onPause();
	}
}
